﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace ADC.Web.Extension
{
    public static class Extensions
    {

        #region Page extension methods

        /// <summary>
        /// Registers the script file.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="key">The key.</param>
        /// <param name="scriptFile">The script file.</param>
        public static void RegisterScriptFile(this Page page, string key, string scriptFile)
        {
            page.ClientScript.RegisterClientScriptInclude(key, scriptFile);
        }

        /// <summary>
        /// Registers the style sheet block.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="styleHref">The styles link</param>
        public static void RegisterStyleSheetFile(this Page page, string key, string styleHref)
        {
            var styleLink = new HtmlLink();
            styleLink.ID = key;
            styleLink.Href = styleHref;
            styleLink.Attributes.Add("rel", "stylesheet");
            styleLink.Attributes.Add("type", "text/css");

            page.Header.Controls.Add(styleLink);
        }

        #endregion
    }
}